#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 1e6 + 10, INF = 1e6;

int n, m;
struct Node{
    int s[2], v, p, size;
    bool flag;

    void init(int _v, int _p){
        v = _v;
        p = _p;
        size = 1;
        flag = false;
    }
}node[N];
int root, idx;




void pushup(int x){
    node[x].size = node[node[x].s[0]].size + node[node[x].s[1]].size + 1;
}
void pushdown(int u){
    if(node[u].flag){
        swap(node[u].s[0], node[u].s[1]);
        node[node[u].s[0]].flag ^= 1;
        node[node[u].s[1]].flag ^= 1;
        node[u].flag = false;
    }
}

void rotate(int x){
    int y = node[x].p, z = node[y].p;
    int k = (node[y].s[1] == x);

    node[z].s[node[z].s[1] == y] = x, node[x].p = z;
    node[y].s[k] = node[x].s[k ^ 1], node[node[x].s[k ^ 1]].p = y;
    node[x].s[k ^ 1] = y, node[y].p = x;
    pushup(y), pushup(x);
}


void splay(int x, int k){
    while(node[x].p != k){
        int y = node[x].p, z = node[y].p;
        if(z != k){
            if((node[y].s[1] == x) ^ (node[z].s[1] == y)){
                rotate(x);
            }else{
                rotate(y);
            }
        }
        rotate(x);
    }

    if(!k) root = x;
}


void insert(int v){
    int u = root, p = 0;
    while(u){
        p = u;
        u = node[u].s[node[u].v < v];
    }
    u = ++idx;
    node[u].init(v, p);
    if(p) node[p].s[node[p].v < v] = u;
    splay(u, 0);
}

int get_k(int k){
    int u = root, p = 0;
    while(u){
        pushdown(u);
        if(node[node[u].s[0]].size >= k) u = node[u].s[0];
        else if(node[node[u].s[0]].size + 1 == k) {
            return u;
        }else {
            k -= node[node[u].s[0]].size + 1;
            u = node[u].s[1];
        }
    }
    return -1;
}

void look_in(int u){
    pushdown(u);
    if(node[u].s[0]) look_in(node[u].s[0]);
    if(node[u].v > 0 && node[u].v <= n){
        printf("%d ", node[u].v);
    }
    if(node[u].s[1]) look_in(node[u].s[1]);
}



int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    scanf("%d%d", &n, &m);
    for(int i = 0; i <= n + 1; i ++){
        insert(i);
    }

    int l, r;
    while(m --){
        scanf("%d%d", &l, &r);
        l = get_k(l), r = get_k(r + 2);
        splay(l, 0), splay(r, l);
        node[node[r].s[0]].flag ^= 1;
    }
    look_in(root);
    return 0;
}